package com.mjp.learn.design.singleton;

/**
 * 饿汉式
 * 饿汉式保证线程安全,但是会导致当用不到时也会加载实例
 */
public class Mg01 {
    private static final Mg01 INSTANCE = new Mg01();

    private Mg01(){

    }

    public static Mg01 getInstance(){
        return INSTANCE;
    }

    public static void main(String[] args){
        Mg01 mg01 = Mg01.getInstance();
        Mg01 mg02 = Mg01.getInstance();
        System.out.println(mg01 == mg02);
    }
}
